import numpy as np
from scipy import *
import scipy.io as io

import net_analysis as na

from brian import *

import matplotlib.pyplot as plt
import shelve
import pickle
import time
import shutil
from datetime import datetime
import sys, os

def correlations(filelist):
    
    filelist_2=[]

    for s in filelist:
        if s.find('corr')!=-1:
            filelist_2.append(s)

    ii=-1;
    for s in filelist_2:
        ii=ii+1
        print 'Press '+ str(ii) + ' to get: ' + s
        
    kin = raw_input('... ')
    
    try:
        kin = int( kin )
    except:
        print( "Invalid number" )
    
    file_selected=filelist_2[kin]

    correlation=shelve.open(file_selected,protocol=-2)
    
    na.plot_correlations(correlation['c_anal'])

    
        


def largeevents(filelist,spbool='No'):
    
    filelist_2=[]

    for s in filelist:
        if s.find('largeevent')!=-1:
            filelist_2.append(s)

    filelist_3=[]
    if spbool=='No':
        for s in filelist_2:
            if s.find('_nsp')!=-1:
                filelist_3.append(s)
    elif spbool=='No':
         for s in filelist_2:
            if s.find('_nsp')==-1:
                filelist_3.append(s)

    l_ev={}
    ii=-1
    for s in filelist_3:
        ii=ii+1
        l_ev[ii]=shelve.open(s,protocol=-2)


    import pdb; pdb.set_trace()
    na.plot_comparison_summary(l_ev[0]['largeevent'],l_ev[1]['largeevent']) #u should check first that exc and clu are correct!!

   
